package financial.sharing.center.common.enums;

/**
 * 	当前发票数据，含税金额为正或者0的，为蓝票；含税金额为负的，为红票。
 */
public enum InvoiceColorEnum {

    无("无", 0),
    蓝票("蓝票", 1),
    红票("红票", 2);

    private final String name;
    private final Integer code;

    InvoiceColorEnum(String name, Integer code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return this.name;
    }

    public Integer getCode() {
        return this.code;
    }

    public static InvoiceColorEnum name2Enum(String code) {
        for (InvoiceColorEnum enumName : InvoiceColorEnum.values()) {
            if(enumName.getName().equals(code)) {
                return enumName;
            }
        }
        return null;
    }

    public static InvoiceColorEnum int2Enum(Integer code) {
        for (InvoiceColorEnum enumName : InvoiceColorEnum.values()) {
            if(enumName.getCode().equals(code)) {
                return enumName;
            }
        }
        return null;
    }
}